package effect;

import java.util.ArrayList;
import java.util.List;

import card.BuildingCard;
import card.Card;
import card.CreatureCard;
import core.Player;
import core.Tile;

public abstract class Effect {

	public enum EffectType {damageModifier, defenceModifier, triggerOnTurnEnd, triggerOnAttackInitiation, 
							triggerInstantly, triggeredByAura, auraTile, auraGlobal, activatable, 
							goldModifier, manaModifier};

	public enum TargetType {tile, creatureCard, buildingCard, none, player};
	
	protected List<EffectType> effectTypes = new ArrayList<EffectType>();
	protected String name;
	protected String description;
	protected String imageName;
	/** Determines if the Effect is shown on card info **/
	protected boolean isVisible = true;
	protected boolean isDispellable = false;
	protected TargetType targetType = TargetType.tile;
	protected int goldCost = 0;
	protected int manaCost = 0;
	
	public int getGoldCost() {
		return goldCost;
	}

	public void setGoldCost(int goldCost) {
		this.goldCost = goldCost;
	}

	public int getManaCost() {
		return manaCost;
	}

	public void setManaCost(int manaCost) {
		this.manaCost = manaCost;
	}

	/**
	 * Called if Effect is a damageModifier.
	 * @param baseMinimumDamage
	 * @return
	 */
	public int getAddedMinimumDamage(int baseMinimumDamage){
		return 0;
	}
	
	/**
	 * Called if Effect is a damageModifier.
	 * @param baseMaximumDamage
	 * @return
	 */
	public int getAddedMaximumDamage(int baseMaximumDamage){
		return 0;
	}
	
	/**
	 * Called if Effect is a defenseModifier.
	 * @param baseDefense
	 * @return
	 */
	public int getAddedDefence(int baseDefense){
		return 0;
	}
	
	/**
	 * Called if Effect is a goldModifier.
	 * @param baseGoldIncome
	 * @return
	 */
	public int getAddedGold(int baseGoldIncome){
		return 0;
	}
	
	/**
	 * Called if Effect is a manaModifier.
	 * @param baseManaIncome
	 * @return
	 */
	public int getAddedMana(int baseManaIncome){
		return 0;
	}
	
	/**
	 * Called if Effect is triggerOnTurnEnd.
	 */
	public void triggerOnTurnEnd(){
		
	}
	
	
	
	/**
	 * Called if Effect is triggerOnAttack.
	 */
	public void triggerOnAttackInitiation(core.Tile attack, core.Tile defend){
		
	}
	
	/**
	 * Called if Effect is triggerInstantly.
	 */
	public void triggerInstantly(){
		
	}
	

	/**
	 * Called if Effect is auraGlobal
	 */
	public void triggerAuraGlobal(){
		
	}




	/**
	 * Called if Effect is auraTile
	 */
	public void triggerAuraTile(){
		
	}
	
	
	
	public boolean isTargetType(TargetType t){
		return t.equals(targetType);
	}
	
	/**
	 * Called if Effect is activatable and has TargetType tile.
	 */
	public void activate(Tile tile){
		
	}
	/**
	 * Called if Effect is activatable and has TargetType creatureCard.
	 */
	public void activate(CreatureCard card){
		
	}
	/**
	 * Called if Effect is activatable and has TargetType buildingCard.
	 */
	public void activate(BuildingCard card){
		
	}
	/**
	 * Called if Effect is activatable and has TargetType player.
	 */
	public void activate(Player player){
		
	}
	/**
	 * Called if Effect is activatable and has TargetType none.
	 */
	public void activate(){
		
	}
	public boolean canActivate(Tile t){
		return true;
	}
	public boolean canActivate(Card card){
		return true;
	}
	public boolean canActivate(Player player){
		return true;
	}
	public boolean canActivate(){
		return true;
	}
	


	public boolean isEffectType(EffectType type){
		if(effectTypes.contains(type))
			return true;
		else
			return false;
	}
	
	public String getName(){
		return name;
	}
	/** May be overridden for flexible descriptions **/
	public String getDescription(){
		return description;
	}
	public String getImageName(){
		return imageName;
	}
	/** determines weather or not the effect should be shown in card information **/
	public boolean isVisible(){
		return isVisible;
	}
	public boolean isDispellable(){
		return isDispellable;
	}	
}
